'use strict';

angular.module('snPaas_om').service('adminStore',['$http','$q','baseUrl',function($http,$q,baseUrl){
	var getAdmin = function(){
		var deferred = $q.defer();
		$http.get(baseUrl.ajax+'/rest/login/getCurrentUser').success(function(data, status, headers, config){
			deferred.resolve(data.data);
		}).error(function(){
			deferred.reject();
		});
		return deferred.promise;
	};
	var logout = function(){
		var deferred = $q.defer();
		$http.get(baseUrl.ajax+'/rest/login/logout').success(function(data, status, headers, config){
			deferred.resolve(data);
		}).error(function(){
			deferred.reject();
		});
		return deferred.promise;
	};
	
	return {
		'getAdmin':getAdmin,
		'logout':logout
	};
}]);